import React, {PureComponent} from 'react'
import Device from './device-detail'
import Bar from './mutli-bar'
import Log from './log'
import Discrete from './discrete'
import Table from 'antd/lib/table'
import Param from './param'
import {connect} from 'react-redux'
import {millToString} from '../../util/util'

/*回流炉*/
class DeviceInfo extends PureComponent {
    render() {
        const {data} = this.props
        const {logs = [], currentSingleBoard = {}, data: param = {}} = data
        const boardData = {
            '程序名': currentSingleBoard.programName,
            '任务令': currentSingleBoard.taskId,
            '编码': currentSingleBoard.encode,
            '加工时间': millToString(currentSingleBoard.processDate),
        }

        const watchData = {
            '程序名': currentSingleBoard.programName,
            '任务令': currentSingleBoard.taskId,
            '编码': currentSingleBoard.encode,
            '加工时间': millToString(currentSingleBoard.processDate),
        }

        const pieData = {
            title: '设备今日运行状况',
            option: {},
            data: [{
                value: 100,
                name: '正常'
            }, {
                value: 0,
                name: '未完成'
            }, {
                value: 0,
                name: '故障'
            }]
        }

        const columns = [
            {
                title: '项目',
                dataIndex: 'xm',
                key: 'name',
            }, {
                title: '链数',
                dataIndex: 'ls',
                key: 'age',
            }, {
                title: '残氧量',
                dataIndex: 'cyl',
                key: 'address',
            }
        ];


        const params = [];

        params.push({
            xm: '设置',
            ls: param.conveyorsspeed + '	cm/min',
            cyl: param.oxygensvalue + 'PPM'
        }, {
            xm: '实际',
            ls: param.conveyoraspeed + '	cm/min',
            cyl: param.oxygenavalue + 'PPM'
        }, {
            xm: '范围',
            ls: '±0.' + param.conveyorrange + '	cm/min',
            cyl: '0~' + param.conveyorrangevalue + 'PPM'
        }, {
            xm: '状态',
            ls: '正常',
            cyl: '正常'
        })

        return (
            <Device src="../images/business/reflow.png" data={data} currentSingleBoard={boardData} pieData={pieData}>
                <div className="device-res">
                    <div className="device-res-col12">
                        <Bar data={param.info||[]}/>
                    </div>
                    <div className="device-res-col6">
                        <Param columns={columns} data={params}/>
                    </div>
                    <div className="device-res-col6">
                        <Log title="设备告警日志" logs={logs}/>
                    </div>
                </div>

            </Device>
        )
    }

}

function mapStoreToProps({deviceMetrics}) {
    return {
        data: deviceMetrics.get('reflow').toJS()
    }
}

export default connect(mapStoreToProps)(DeviceInfo)

